<!-- 话题Item组件 -->
<template>
	<view class="topic_item">
		<view style="height:70rpx;opacity: 0;"></view>
		<view class="item" v-for="(item,index) in dataList">
			<view class="top" @click="goDetail(item.id)">
				<view class="left">
						<avatar class="icon" :src="item.headPortrait"></avatar>
					<view><text>{{item.nickName}}`</text>发布</view>
				</view>
				<view class="right">
					<text>{{item.readNum}}</text>参与
				</view>
			</view>

			<view class="title" @click="goDetail(item.id)">
				<view>{{item.title}}</view>
			</view>
			<view class="texts" v-if="item.workKey">
				<view class="mr10" v-for="(cell,idx) in item.words" :key="idx" @click.stop='topicList(cell)'>#{{cell}}#</view>
			</view>
			<view class="createTime" v-if='!item.topping'>{{item.createTime}}</view>
            <image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/bg1.png" class="img_position"></image>
			<!-- 以下内容用于我的发布话题 -->
			<view v-if="isMyFb" class="isMyFb">
				<view><text>{{item.num2}}</text>人发布</view>
				<view>发起于: <text>{{item.time}}</text> </view>
			</view>
			<image v-if="isMyFb" class="status" :src="item.status"></image>
		</view>
	</view>
</template>

<script>
	import avatar from '@/components/avatar.vue'
	export default {
		components:{
			avatar
		},
		props: {
			dataList: {
				type: Array,
				default: () => []
			},
			isMyFb: {
				type: Boolean,
				default: false
			},
			keyword:String,
		},
		data() {
			return {
			}
		},
		methods: {
			goDetail(id) {
				console.log(id)
				uni.navigateTo({
					url: `/pages/topic/topicDetail/topicDetail?id=${id}`
				})
			},
			topicList(cell){
				if(cell==this.keyword){
					return 
				}else{
					uni.navigateTo({
						url:'/pages/topic/topicList/topicList?key='+cell
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.topic_item {
		// margin-top: 100rpx;
		width: 100%;
		height: 100%;
		padding: 8rpx 32rpx 0 30rpx;
		background-color: #F8F8F8;
		box-sizing: border-box;
		.item {
			position: relative;
			width: 100%;
			margin-top: 26rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			background-color: #fff;
			overflow: hidden;
			
            .img_position{
				width: 156rpx;
				height: 146rpx;
				position: absolute;
				right: 0;
				top: 150rpx;
			}
			.status {
				width: 114rpx;
				height: 106rpx;
				position: absolute;
				right: 10rpx;
				top: 70rpx;
			}

			.isMyFb {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 24rpx 40rpx;
				font-size: 26rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #959595;
			}
            
			.createTime{
				font-size: 26rpx;
				padding: 0 0 22rpx 22rpx;
				font-family: PingFang SC;
				color: #B6B6B6;
			}
			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 42rpx 26rpx 34rpx;
				border-bottom: 1rpx dashed #E5EAE9;

				.left {
					display: flex;
					align-items: center;

					.icon {
						width: 52rpx;
						height: 52rpx;
						margin-right: 22rpx;
						border-radius: 50%;
						overflow: hidden;
					}

					view {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #7E7E7E;
					}
				}

				.right {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #7E7E7E;
				}
			}

			.title {
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #303030;
				padding: 34rpx 24rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				word-break: break-all;
			}

			.texts {
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				padding: 0 22rpx 22rpx;

				view {
					margin-right: 26rpx;
					font-size: 26rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #4F9BF1;
				}
			}
		}
	}
</style>
